Skip to content

Conversation

@saishreeeee
Copy link
Contributor

@saishreeeee saishreeeee commented Jun 19, 2025

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • Other

Description

Add functionality for export of latency logs via telemetry

Example latency log:
{
"frontend_log_event_id": "30565427-1299-4fbc-bec0-25378cfe912b",
"context": {
"client_context": {
"timestamp_millis": 1750592858108,
"user_agent": "PyDatabricksSqlConnector/4.0.4"
}
},
"entry": {
"sql_driver_log": {
"session_id": "01f04f5e-b1a8-1dd1-962a-e40efd092bdd",
"system_configuration": {
"driver_version": "4.0.4",
"os_name": "Darwin",
"os_version": "24.5.0",
"os_arch": "arm64",
"runtime_name": "Python 3.13.3",
"runtime_version": "3.13.3",
"runtime_vendor": "CPython",
"driver_name": "Databricks SQL Python Connector",
"char_set_encoding": "utf-8",
"locale_name": "en_US"
},
"driver_connection_params": {
"http_path": "/sql/1.0/warehouses/864004c1b3961382",
"mode": "THRIFT",
"host_info": {
"host_url": "e2-dogfood.staging.cloud.databricks.com",
"port": 443
},
"auth_mech": "PAT"
},
"sql_statement_id": "01f04f5e-b1d6-1a1e-afe4-e99e1ccb8805",
"sql_operation": {
"statement_type": "sql",
"is_compressed": true,
"execution_result": "inline_arrow",
"retry_count": 0
},
"operation_latency_ms": 518
}
}
}

How is this tested?

  • Unit tests
  • E2E Tests
  • Manually
  • N/A

Related Tickets & Documents

PECOBLR-554

Signed-off-by: Sai Shree Pradhan <[email protected]>
…ze and get telemetry client

Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
…pTelemetryClient class with NOOP_TELEMETRY_CLIENT singleton, updated tests accordingly

Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
@github-actions
Copy link

github-actions bot commented Jul 2, 2025

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

@github-actions
Copy link

github-actions bot commented Jul 2, 2025

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

Signed-off-by: Sai Shree Pradhan <[email protected]>
@github-actions
Copy link

github-actions bot commented Jul 2, 2025

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

Signed-off-by: Sai Shree Pradhan <[email protected]>
@github-actions
Copy link

github-actions bot commented Jul 3, 2025

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

Copy link
Contributor

@jprakash-db jprakash-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks for the making the changes

Signed-off-by: Sai Shree Pradhan <[email protected]>
@github-actions
Copy link

github-actions bot commented Jul 3, 2025

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

@saishreeeee saishreeeee merged commit 0dfe0f4 into telemetry Jul 3, 2025
23 of 27 checks passed
saishreeeee added a commit that referenced this pull request Jul 22, 2025
* send telemetry to unauth endpoint in case of connection/auth errors

Signed-off-by: Sai Shree Pradhan <[email protected]>

* formatting

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added unit test for send_connection_error_telemetry

Signed-off-by: Sai Shree Pradhan <[email protected]>

* retry errors

Signed-off-by: Sai Shree Pradhan <[email protected]>

* Add functionality for export of latency logs via telemetry (#608)

* added functionality for export of failure logs

Signed-off-by: Sai Shree Pradhan <[email protected]>

* changed logger.error to logger.debug in exc.py

Signed-off-by: Sai Shree Pradhan <[email protected]>

* Fix telemetry loss during Python shutdown

Signed-off-by: Sai Shree Pradhan <[email protected]>

* unit tests for export_failure_log

Signed-off-by: Sai Shree Pradhan <[email protected]>

* try-catch blocks to make telemetry failures non-blocking for connector operations

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed redundant try/catch blocks, added try/catch block to initialize and get telemetry client

Signed-off-by: Sai Shree Pradhan <[email protected]>

* skip null fields in telemetry request

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed dup import, renamed func, changed a filter_null_values to lamda

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed unnecassary class variable and a redundant try/except block

Signed-off-by: Sai Shree Pradhan <[email protected]>

* public functions defined at interface level

Signed-off-by: Sai Shree Pradhan <[email protected]>

* changed export_event and flush to private functions

Signed-off-by: Sai Shree Pradhan <[email protected]>

* formatting

Signed-off-by: Sai Shree Pradhan <[email protected]>

* changed connection_uuid to thread local in thrift backend

Signed-off-by: Sai Shree Pradhan <[email protected]>

* made errors more specific

Signed-off-by: Sai Shree Pradhan <[email protected]>

* revert change to connection_uuid

Signed-off-by: Sai Shree Pradhan <[email protected]>

* reverting change in close in telemetry client

Signed-off-by: Sai Shree Pradhan <[email protected]>

* JsonSerializableMixin

Signed-off-by: Sai Shree Pradhan <[email protected]>

* isdataclass check in JsonSerializableMixin

Signed-off-by: Sai Shree Pradhan <[email protected]>

* convert TelemetryClientFactory to module-level functions, replace NoopTelemetryClient class with NOOP_TELEMETRY_CLIENT singleton, updated tests accordingly

Signed-off-by: Sai Shree Pradhan <[email protected]>

* renamed connection_uuid as session_id_hex

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added NotImplementedError to abstract class, added unit tests

Signed-off-by: Sai Shree Pradhan <[email protected]>

* formatting

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added PEP-249 link, changed NoopTelemetryClient implementation

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed unused import

Signed-off-by: Sai Shree Pradhan <[email protected]>

* made telemetry client close a module-level function

Signed-off-by: Sai Shree Pradhan <[email protected]>

* unit tests verbose

Signed-off-by: Sai Shree Pradhan <[email protected]>

* debug logs in unit tests

Signed-off-by: Sai Shree Pradhan <[email protected]>

* debug logs in unit tests

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed ABC from mixin, added try/catch block around executor shutdown

Signed-off-by: Sai Shree Pradhan <[email protected]>

* checking stuff

Signed-off-by: Sai Shree Pradhan <[email protected]>

* finding out

* finding out more

* more more finding out more nice

* locks are useless anyways

* haha

* normal

* := looks like walrus horizontally

* one more

* walrus again

* old stuff without walrus seems to fail

* manually do the walrussing

* change 3.13t, v2

Signed-off-by: Sai Shree Pradhan <[email protected]>

* formatting, added walrus

Signed-off-by: Sai Shree Pradhan <[email protected]>

* formatting

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed walrus, removed test before stalling test

Signed-off-by: Sai Shree Pradhan <[email protected]>

* changed order of stalling test

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed debugging, added TelemetryClientFactory

Signed-off-by: Sai Shree Pradhan <[email protected]>

* remove more debugging

Signed-off-by: Sai Shree Pradhan <[email protected]>

* latency logs funcitionality

Signed-off-by: Sai Shree Pradhan <[email protected]>

* fixed type of return value in get_session_id_hex() in thrift backend

Signed-off-by: Sai Shree Pradhan <[email protected]>

* debug on TelemetryClientFactory lock

Signed-off-by: Sai Shree Pradhan <[email protected]>

* formatting

Signed-off-by: Sai Shree Pradhan <[email protected]>

* type notation for _waiters

Signed-off-by: Sai Shree Pradhan <[email protected]>

* called connection.close() in test_arraysize_buffer_size_passthrough

Signed-off-by: Sai Shree Pradhan <[email protected]>

* run all unit tests

Signed-off-by: Sai Shree Pradhan <[email protected]>

* more debugging

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed the connection.close() from that test, put debug statement before and after TelemetryClientFactory lock

Signed-off-by: Sai Shree Pradhan <[email protected]>

* more debug

Signed-off-by: Sai Shree Pradhan <[email protected]>

* more more more

Signed-off-by: Sai Shree Pradhan <[email protected]>

* why

Signed-off-by: Sai Shree Pradhan <[email protected]>

* whywhy

Signed-off-by: Sai Shree Pradhan <[email protected]>

* thread name

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added teardown to all tests except finalizer test (gc collect)

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added the get_attribute functions to the classes

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed tearDown, added connection.close() to first test

Signed-off-by: Sai Shree Pradhan <[email protected]>

* finally

Signed-off-by: Sai Shree Pradhan <[email protected]>

* remove debugging

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added test for export_latency_log, made mock of thrift backend with retry policy

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added multi threaded tests

Signed-off-by: Sai Shree Pradhan <[email protected]>

* formatting

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added TelemetryExtractor, removed multithreaded tests

Signed-off-by: Sai Shree Pradhan <[email protected]>

* formatting

Signed-off-by: Sai Shree Pradhan <[email protected]>

* fixes in test

Signed-off-by: Sai Shree Pradhan <[email protected]>

* fix in telemetry extractor

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added doc strings to latency_logger, abstracted export_telemetry_log

Signed-off-by: Sai Shree Pradhan <[email protected]>

* statement type, unit test fix

Signed-off-by: Sai Shree Pradhan <[email protected]>

* unit test fix

Signed-off-by: Sai Shree Pradhan <[email protected]>

* statement type changes

Signed-off-by: Sai Shree Pradhan <[email protected]>

* test_fetches fix

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added mocks to resolve the errors caused by log_latency decorator in tests

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed function in test_fetches cuz it is only used once

Signed-off-by: Sai Shree Pradhan <[email protected]>

* added _safe_call which returns None in case of errors in the get functions

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed the changes in test_client and test_fetches

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed the changes in test_fetches

Signed-off-by: Sai Shree Pradhan <[email protected]>

* test_telemetry

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed test

Signed-off-by: Sai Shree Pradhan <[email protected]>

---------

Signed-off-by: Sai Shree Pradhan <[email protected]>

* MaxRetryDurationError

Signed-off-by: Sai Shree Pradhan <[email protected]>

* main changes

Signed-off-by: Sai Shree Pradhan <[email protected]>

* formatting

Signed-off-by: Sai Shree Pradhan <[email protected]>

* import json

Signed-off-by: Sai Shree Pradhan <[email protected]>

* without the max retry errors

Signed-off-by: Sai Shree Pradhan <[email protected]>

* unauth telemetry client

Signed-off-by: Sai Shree Pradhan <[email protected]>

* remove duplicate code setting telemetry_enabled

Signed-off-by: Sai Shree Pradhan <[email protected]>

* removed unused errors

Signed-off-by: Sai Shree Pradhan <[email protected]>

* merge with main changes

Signed-off-by: Sai Shree Pradhan <[email protected]>

* test

Signed-off-by: Sai Shree Pradhan <[email protected]>

* without try/catch block

Signed-off-by: Sai Shree Pradhan <[email protected]>

* -

Signed-off-by: Sai Shree Pradhan <[email protected]>

* error log for auth provider, ThriftDatabricksClient

Signed-off-by: Sai Shree Pradhan <[email protected]>

* error log for session.open

Signed-off-by: Sai Shree Pradhan <[email protected]>

* retry tests fix

Signed-off-by: Sai Shree Pradhan <[email protected]>

* test connection failure log

Signed-off-by: Sai Shree Pradhan <[email protected]>

* check types fix

Signed-off-by: Sai Shree Pradhan <[email protected]>

* test

Signed-off-by: Sai Shree Pradhan <[email protected]>

* rephrase import

Signed-off-by: Sai Shree Pradhan <[email protected]>

---------

Signed-off-by: Sai Shree Pradhan <[email protected]>
@saishreeeee saishreeeee deleted the PECOBLR-554 branch August 1, 2025 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants